<template>
	<view>
		<view class="head">
			<text class="title" v-if="info.status == 1">进行中</text>
			<text class="title" v-if="info.status == 2">已完成</text>
			<text class="title" v-if="info.status == 3">已退款</text>
		</view>
		
		<view class="time-money-box">
			<view class="time-money z-margin-t-24">
				<view class="">
					<view class="main">{{formatTime(info.overtime-info.starttime)}}</view>
					<view class="minor">已消费时间</view>
				</view>
				<view class="z-margin-l-48">
					<view class="main" style="color: #FF7B18;">{{info.allprice}}</view>
					<view class="minor" v-if="info.status == 1">已消费团购核销金额</view>
					<view class="minor" v-if="info.status == 2">团购系统核算金额（以美团/抖音定价为准）</view>
				</view>
			</view>
			
			<template v-if="info.status == 2">
				<view class="z-margin-t-32"></view>
				<u-line length="622rpx" style="margin: auto;"></u-line>
				<view class="z-flex-x-s-b z-margin-t-24">
					<view class="minor">微信续费金额</view>
					<view class="main">￥{{info.price}}</view>
				</view>
				<view class="z-flex-x-s-b z-margin-t-24">
					<view class="minor">余额续费金额</view>
					<view class="main">￥{{info.money}}</view>
				</view>
				<view class="z-flex-x-s-b z-margin-t-24">
					<view class="minor">实收款（微信支付台费：￥0，余额支付台费：￥0）</view>
					<view class="main">￥{{Number(ifno.price) + Number(info.money)}}</view>
				</view>
				<view class="z-flex-x-s-b z-margin-t-24">
					<view class="minor">优惠金额</view>
					<view class="main">￥{{info.coupon_price}}</view>
				</view>
				<view class="z-flex-x-s-b z-margin-t-24">
					<view class="minor">顾客当前余额</view>
					<view class="main">￥{{info.user_money}}</view>
				</view>
			</template>
		</view>
		
		<view class="order-info">
			<view class="title">订单信息</view>
			
			<view class="z-flex-x-s-b z-margin-t-24">
				<view class="minor">订单编号</view>
				<view class="main">{{info.orderId}}</view>
			</view>
			<view class="z-flex-x-s-b z-margin-t-24">
				<view class="minor">团购类型</view>
				<view class="main">
					<text v-if="info.type == 1">免押金开台</text>
					<text v-if="info.type == 2">预付款开台</text>
					<text v-if="info.type == 3">定时开台</text>
					<text v-if="info.type == 4">美团团购核销</text>
					<text v-if="info.type == 5">抖音团购核销</text>
					<text v-if="info.type == 6">月卡开台</text>
				</view>
			</view>
			<view class="z-flex-x-s-b z-margin-t-24">
				<view class="minor">团购时长</view>
				<view class="main">{{info.duration}}</view>
			</view>
			<view class="z-flex-x-s-b z-margin-t-24">
				<view class="minor">开台时间</view>
				<view class="main">{{info.starttime | date('yyyy/mm/dd hh:MM')}}</view>
			</view>
			<view class="z-flex-x-s-b z-margin-t-24">
				<view class="minor">开台方式</view>
				<view class="main" v-if="info.createtype == 0">自助开台</view>
				<view class="main" v-if="info.createtype == 1">门店开台</view>
			</view>
			<view class="z-flex-x-s-b z-margin-t-24">
				<view class="minor">客户昵称</view>
				<view class="main">{{info.nickname}}</view>
			</view>
			<view class="z-flex-x-s-b z-margin-t-24">
				<view class="minor">客户手机号</view>
				<view class="main">{{info.mobile}} <text class="copy" @click="$copy(info.mobile)">复制</text> <text class="bohao" @click="dial(info.mobile)">拨号</text> </view>
			</view>
		</view>
		
		<view class="btn-box">
			<view class="PlaceAnOrder-btn" v-if="info.status == 1" @click="">结束订单</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:'',
				info:{}
			}
		},
		onLoad(op) {
			this.id = op.id
			this.getInfo()
		},
		methods: {
			getInfo(){
				this.$api.post('/orderDetail', {
					id:this.id
				}).then((res) => {
					if (res.data) {
						this.info = res.data
					}
				}).catch((res) => {});
			},
			dial(e){
				uni.makePhoneCall({
					phoneNumber:e
				});
			},
			formatTime(seconds) {
			    // 计算小时、分钟和秒
			    const hours = Math.floor(seconds / 3600);
			    const minutes = Math.floor((seconds % 3600) / 60);
			    const remainingSeconds = seconds % 60;
			
			    // 格式化输出
			    const formattedHours = String(hours).padStart(2, '0');
			    const formattedMinutes = String(minutes).padStart(2, '0');
			    const formattedSeconds = String(remainingSeconds).padStart(2, '0');
			
			    return `${formattedHours}:${formattedMinutes}:${formattedSeconds}`;
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F7F8FA;
	}
	.head {
		width: 750rpx;
		height: 333rpx;
		background: linear-gradient(to bottom, #E4F6F1,#E5F4F5, #F7F8FA);
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		
		.title {
			font-weight: 800;
			font-size: 56rpx;
			color: #1C274C;
			padding: 40rpx 0 0 32rpx;
		}
	}
	
	.time-money-box {
		padding: 32rpx;
		width: 622rpx;
		margin: auto;
		background: #FFFFFF;
		position: relative;
		top: -200rpx;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		
		.time-money {
			display: flex;
			
			.main {
				font-weight: bold;
				font-size: 44rpx;
			}
			.minor {
				font-weight: 500;
				font-size: 22rpx;
				color: #A4A9B7;
				margin-top: 16rpx;
			}
		}
		
		.main {
			font-weight: 500;
			font-size: 24rpx;
			color: #1C274C;
		}
		.minor {
			font-weight: 500;
			font-size: 24rpx;
			color: #A4A9B7;
		}
	}
	
	
	
	
	
	.order-info {
		padding: 32rpx;
		width: 622rpx;
		margin: auto;
		background: #FFFFFF;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		position: relative;
		top: -170rpx;
		.title {
			font-weight: bold;
			font-size: 30rpx;
			color: #1C274C;
		}
		.main {
			font-weight: 500;
			font-size: 24rpx;
			color: #1C274C;
			.copy {
				font-weight: 500;
				font-size: 24rpx;
				color: #A4A9B7;
				padding: 0 32rpx;
			}
			.bohao {
				color: #4BC264;
			}
		}
		.minor {
			font-weight: 500;
			font-size: 24rpx;
			color: #A4A9B7;
		}
	}
	
	
	.btn-box {
		width: 100%;
		position: fixed;
		bottom: 40rpx;
		z-index: 9;
		.PlaceAnOrder-btn {
			width: 686rpx;
			height: 106rpx;
			margin: auto;
			background: #4bc264;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			font-weight: 800;
			font-size: 34rpx;
			color: #ffffff;
			line-height: 106rpx;
			text-align: center;
		}
	}
</style>
